package 曾世昌12_19.demo5;

import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.ArrayList;
import java.util.List;

public class test {
    public static void main(String[] args) throws Exception {
        List<Element> student = new SAXReader().read( "E:\\untitled5\\src\\rc\\demo12_19\\demo5\\Sut.xml" ).getRootElement().elements( "student" );
        ArrayList<Student> stu = new ArrayList<>();
        for (Element element : student) {
            stu.add( new Student( element.attributeValue( "stuNo" ), element.elementText( "name" ),
                    Integer.parseInt( element.elementText( "age" ) ), element.elementText( "sex" ),
                    Integer.parseInt( element.elementText( "score" ) ) ) );
        }
        System.out.println(stu);
    }
}
